package hadoopLearn;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;

public class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
    public void map(LongWritable v1, Text k1, Context context) throws IOException, InterruptedException{
        String line = k1.toString();
        System.out.println(line);

        if(line.contains("name")){
            return;
        }
        String[] splits = k1.toString().split(" ");
        if(splits.length != 2)
            return;
        Text name = new Text(splits[0]);
        System.out.println("Map: " + name.toString());
        int score = Integer.parseInt(splits[1]);
        context.write(name, new IntWritable(score));
    }
}
